package com.situ.mall.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.common.entity.Worker;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-01-29
 */
public interface WorkerMapper extends BaseMapper<Worker> {

    /* 前端请求 */
    //查电话号码有没有被注册
    @Select("select * from worker where tel = #{tel}")
    Worker selectByTel(String tel);

    //查该用户账号有没有注册过陪诊员
    @Select("select * from worker where member_id = #{memberId}")
    Worker selectByMemberId(Integer memberId);

    //注册保存
    @Insert("insert into worker(avatar, background_pic, nickname, name, sex, tel, password, age, status, work_day, ID_pic_front, ID_pic_back, member_id) values (#{avatar}, #{backgroundPic}, #{nickname}, #{name}, #{sex}, #{tel}, #{password}, #{age}, #{status}, #{workDay}, #{idPicFront}, #{idPicBack}, #{memberId})")
    void register(Worker worker);

    //token存入数据库
    @Insert("update sport.worker set token = #{token} where id = #{id}")
    void insertToken(String token, Integer id);

    //编辑个人资料
    void updateInfo(Worker worker);


    /* 后端操作 */
    //查询渲染表格
    List<Worker> list(@Param("name")String name, @Param("tel")String tel);

}
